package com.lqs.blog.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lqs.blog.mapper.AdminMapper;
import com.lqs.blog.pojo.Admin;
import com.lqs.blog.pojo.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {
    @Autowired
    private AdminMapper mapper;

    public Admin findAdminByUsername(String username) {
        LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Admin::getUsername, username);
        wrapper.last("limit 1");
        return mapper.selectOne(wrapper);
    }

    public List<Permission> findPermissionByAdminId(Long id) {
        return mapper.findPermissionByAdminId(id);
    }
}
